require.config({
                baseUrl:"../",
	paths:{
		bsl:'bsl',

	}
});
require(['bsl'],function(bsl){
	document.addEventListener('deviceready', onDeviceready, false);
        function onDeviceready(){
            alert("star");
        
        function getCurrentHead() {
        bsl.orientation.getCurrentHeading(onSuccess1, onError1);
        }
        
        function onSuccess1(heading) {
        alert('Heading: ' + heading.magneticHeading);
        }
        
        function onError1(compassError) {
        alert('Compass Error: ' + compassError.code);
        }
        
        function startWatch() {
        
        // Update compass every 3 seconds
        var options = { frequency: 300 };
        
        watchID = bsl.orientation.watchHeading(onSuccess, onError, options);
        }
        
        function stopWatch() {
        if (watchID) {
        bsl.orientation.clearWatch(watchID);
        watchID = null;
        }
        }
        
        function onSuccess(heading) {
        var element = document.getElementById('heading');
        element.innerHTML = 'Heading: ' + heading.magneticHeading;
        }
        
        function onError(compassError) {
        alert('Compass error: ' + compassError.code);
        }
    document.getElementById("getCurrentHeading").addEventListener("click",getCurrentHead,false);
    document.getElementById("startWatch").addEventListener("click",startWatch,false);
    document.getElementById("stopWatch").addEventListener("click",stopWatch,false);
        }
        
});